﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using FAS.Objetos;
using System.Xml;
using System.IO;

namespace FAS.App_Code
{
    public class Auxiliar
    {
        internal static Boolean validaVacio(Control.ControlCollection controles){
            foreach (Control cT in controles)
                foreach (Control c in cT.Controls)
                    if (c is TextBox && c.Text.Equals(String.Empty))
                    {
                        MessageBox.Show("Error: Datos Incompletos");
                        return false;
                    }
            return true;
        }

        internal static Boolean validaVacioRTB(params RichTextBox[] controles)
        {
            foreach (RichTextBox cT in controles)
            {
                Boolean mal = cT.Text == String.Empty;
                if (mal)
                {
                    MessageBox.Show("ERROR: DATOS INCORRECTOS");
                    return false;
                }
                
            }
            return true;
        }

        internal static String getIp() 
        {
            XmlDocument xDoc = new XmlDocument();
            xDoc.Load("MConf.xml");
            XmlNodeList par = xDoc.GetElementsByTagName("params");
            XmlNodeList lista =((XmlElement)par[0]).GetElementsByTagName("server");
            XmlNodeList nodoip = ((XmlElement)lista[0]).GetElementsByTagName("ip");
            String ip = nodoip[0].InnerText;
            return ip;
        }
        internal static String getUser()
        {
            XmlDocument xDoc = new XmlDocument();
            xDoc.Load("MConf.xml");
            XmlNodeList par = xDoc.GetElementsByTagName("params");
            XmlNodeList lista = ((XmlElement)par[0]).GetElementsByTagName("user");
            XmlNodeList nodoip = ((XmlElement)lista[0]).GetElementsByTagName("name");
            String ip = nodoip[0].InnerText;
            return ip;
        }
        internal static String getPass()
        {
            XmlDocument xDoc = new XmlDocument();
            xDoc.Load("MConf.xml");
            XmlNodeList par = xDoc.GetElementsByTagName("params");
            XmlNodeList lista = ((XmlElement)par[0]).GetElementsByTagName("user");
            XmlNodeList nodoip = ((XmlElement)lista[0]).GetElementsByTagName("password");
            String ip = nodoip[0].InnerText;
            return ip;
        }


    }
}
